package com.itheima.d1_create;

/**
 * method1:继承Thread类实现:调用start方法运行
 * 缺点：线程类已经继承了Thread，无法继承其他类，不利于扩展
 */
public class demo1 {
    public static void main(String[] args) {
        Thread thread = new MyThread();
        thread.start();
        for (int i = 0; i < 5; i++) {
            System.out.println("MainThread execute"+ i);
        }
    }


}
class MyThread extends Thread{//自定义线程类需要继承线程类Thread
    @Override
    public void run(){
        for (int i = 0; i < 5; i++) {
            System.out.println("SubThread execute"+ i);
        }
    }
}